**************************************************************
*HURRICANES AND GAS GOUGING - APPENDIX HURRICANE EVENT STUDIES
**************************************************************
frame copy default hur_regs, replace
frame change hur_regs
keep if sample_main==1
gsort station_id date


********************************
*EVENT STUDY: BONNIE-CHARLIE
*
*Hurricane landfalls day 0
gsort station_id date
gen hur_landfall_d0=0 
	replace hur_landfall_d0=1 if BONCHAR_landfall==1 & date==`=td(12aug2004)'	
*
*Creating 14-day event windows   
gen event_day=. //Event day variable
	replace event_day=0 if hur_landfall_d0==1 
*
*Indicators: 14 Days Prior to Hurricane for Different Samples
forvalues t = 1/14 {
	local n=-1*(`t')
	*Year check
	gen y=f`t'.year
	*Landfall 
	gen hur_landfall_dn`t' = 0
		replace hur_landfall_dn`t' = 1 if f`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`n' if hur_landfall_dn`t'==1
	drop y
}
*
*Indicators: 14 Days After Hurricane
forvalues t = 1/14 {
	*Year check
	gen y=l`t'.year
	*Landfall indicator
	gen hur_landfall_d`t' = 0		
		replace hur_landfall_d`t' = 1 if l`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`t' if hur_landfall_d`t'==1
	drop y		
}
*
order hur_landfall_dn14 hur_landfall_dn13 hur_landfall_dn12 hur_landfall_dn11 ///
      hur_landfall_dn10 hur_landfall_dn9 hur_landfall_dn8 hur_landfall_dn7 ///
	  hur_landfall_dn6 hur_landfall_dn5 hur_landfall_dn4 hur_landfall_dn3 ///
	  hur_landfall_dn2 hur_landfall_dn1 hur_landfall_d0 hur_landfall_d1 ///
	  hur_landfall_d2 hur_landfall_d3 hur_landfall_d4 hur_landfall_d5 ///
	  hur_landfall_d6 hur_landfall_d7 hur_landfall_d8 hur_landfall_d9 ///
	  hur_landfall_d10 hur_landfall_d11 hur_landfall_d12 hur_landfall_d13 ///
	  hur_landfall_d14, last

*Event window indicators 
egen window_landfall=rowtotal(hur_landfall_dn14-hur_landfall_d14)  //Event study - Landfall

*Coefficient variables
gen d=. in 1
gen xb_hur1 = . in 1
	gen hi_hur1 = . in 1
	gen lo_hur1 = . in 1	
gen xb_hur2 = . in 1
	gen hi_hur2 = . in 1
	gen lo_hur2 = . in 1
gen xb_hur3 = . in 1
	gen hi_hur3 = . in 1
	gen lo_hur3 = . in 1
	
*Hurricane Landfall Areas - Price	
reg retail hur_landfall_dn14-hur_landfall_d14 ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)
		
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur1    = r(estimate) in `i'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur1    = r(estimate) in `j'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `j'
}
*
*Hurricane Landfall Areas - wholesale	
reg wholesale hur_landfall_dn14-hur_landfall_d14  ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)	
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur3    = r(estimate) in `i'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur3    = r(estimate) in `j'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `j'
}
*
*Graph - Prices and Wholesale
tw(connected xb_hur1 d, m(T) mfcolor(white) mlcolor(black) msize(medium) lcolor(edkblue) lwidth(medthick) mlwidth(medium)) ///
 (connected xb_hur3 d, m(circle) mfcolor(white) mlcolor(black) msize(medium) lcolor(cranberry) lwidth(medthick) mlwidth(medium)) , ///
	graphr(color(white)) ///
	yscale(noline) ///
	xtit("Days Before/After Hurricane Landfall") ///
	ytit("Price ($/gal)") ///
	legend(label(1 "Retail") ///
		   label(2 "Wholesale") ring(0) position(11) col(1) region(lcolor(white)) )  ///
	text(4 0 "Bonnie/Charlie", size(medium)) ///
	ylabel(0(0.5)4 ,nogrid angle(0)) ///
	xlabel(-14(2)14)  
graph export $figs/bon-char-whole-ret-$outputdate.png, replace
drop event_day-lo_hur3


********************************
*EVENT STUDY: FRANCES 
gsort station_id date
gen hur_landfall_d0=0 
	replace hur_landfall_d0=1 if FRANCES_landfall==1 & date==`=td(06sep2004)'	
*
*Creating 14-day event windows   
gen event_day=. //Event day variable
	replace event_day=0 if hur_landfall_d0==1 
*	
*Indicators: 14 Days Prior to Hurricane for Different Samples
forvalues t = 1/14 {
	local n=-1*(`t')
	*Year check
	gen y=f`t'.year
	*Landfall 
	gen hur_landfall_dn`t' = 0
		replace hur_landfall_dn`t' = 1 if f`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`n' if hur_landfall_dn`t'==1
	drop y
}
*
*Indicators: 14 Days After Hurricane
forvalues t = 1/14 {
	*Year check
	gen y=l`t'.year
	*Landfall indicator
	gen hur_landfall_d`t' = 0		
		replace hur_landfall_d`t' = 1 if l`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`t' if hur_landfall_d`t'==1
	drop y		
}
*
order hur_landfall_dn14 hur_landfall_dn13 hur_landfall_dn12 hur_landfall_dn11 ///
      hur_landfall_dn10 hur_landfall_dn9 hur_landfall_dn8 hur_landfall_dn7 ///
	  hur_landfall_dn6 hur_landfall_dn5 hur_landfall_dn4 hur_landfall_dn3 ///
	  hur_landfall_dn2 hur_landfall_dn1 hur_landfall_d0 hur_landfall_d1 ///
	  hur_landfall_d2 hur_landfall_d3 hur_landfall_d4 hur_landfall_d5 ///
	  hur_landfall_d6 hur_landfall_d7 hur_landfall_d8 hur_landfall_d9 ///
	  hur_landfall_d10 hur_landfall_d11 hur_landfall_d12 hur_landfall_d13 ///
	  hur_landfall_d14, last
egen window_landfall=rowtotal(hur_landfall_dn14-hur_landfall_d14)  //Event study - Landfall
*
*Coefficient variables
gen d=. in 1
gen xb_hur1 = . in 1
	gen hi_hur1 = . in 1
	gen lo_hur1 = . in 1	
gen xb_hur2 = . in 1
	gen hi_hur2 = . in 1
	gen lo_hur2 = . in 1
gen xb_hur3 = . in 1
	gen hi_hur3 = . in 1
	gen lo_hur3 = . in 1
*
*Hurricane Landfall Areas - Price	
reg retail hur_landfall_dn14-hur_landfall_d14 ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)
*		
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur1    = r(estimate) in `i'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur1    = r(estimate) in `j'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `j'
}
*
*Hurricane Landfall Areas - wholesale	
reg wholesale hur_landfall_dn14-hur_landfall_d14  ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)	
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur3    = r(estimate) in `i'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur3    = r(estimate) in `j'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `j'
}
*
*Graph - Prices and Wholesale
tw(connected xb_hur1 d, m(T) mfcolor(white) mlcolor(black) msize(medium) lcolor(edkblue) lwidth(medthick) mlwidth(medium)) ///
 (connected xb_hur3 d, m(circle) mfcolor(white) mlcolor(black) msize(medium) lcolor(cranberry) lwidth(medthick) mlwidth(medium)) , ///
	graphr(color(white)) ///
	yscale(noline) ///
	xtit("Days Before/After Hurricane Landfall") ///
	ytit("Price ($/gal)") ///
	legend(label(1 "Retail") ///
		   label(2 "Wholesale") ring(0) position(11) col(1) region(lcolor(white)) )  ///
	text(4 0 "Frances", size(medium)) ///
	ylabel(0(0.5)4 ,nogrid angle(0)) ///
	xlabel(-14(2)14)  
graph export $figs/frances-whole-ret-$outputdate.png, replace
drop event_day-lo_hur3


********************************
*EVENT STUDY: IVAN 
*Hurricane landfalls day 0
gsort station_id date
gen hur_landfall_d0=0 
	replace hur_landfall_d0=1 if IVAN_landfall==1 & date==`=td(16sep2004)'
*
*Creating 14-day event windows   
gen event_day=. //Event day variable
	replace event_day=0 if hur_landfall_d0==1 
	
*Indicators: 14 Days Prior to Hurricane for Different Samples
forvalues t = 1/14 {
	local n=-1*(`t')
	*Year check
	gen y=f`t'.year
	*Landfall 
	gen hur_landfall_dn`t' = 0
		replace hur_landfall_dn`t' = 1 if f`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`n' if hur_landfall_dn`t'==1
	drop y
}
*
*Indicators: 14 Days After Hurricane
forvalues t = 1/14 {
	*Year check
	gen y=l`t'.year
	*Landfall indicator
	gen hur_landfall_d`t' = 0		
		replace hur_landfall_d`t' = 1 if l`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`t' if hur_landfall_d`t'==1
	drop y		
}
*
order hur_landfall_dn14 hur_landfall_dn13 hur_landfall_dn12 hur_landfall_dn11 ///
      hur_landfall_dn10 hur_landfall_dn9 hur_landfall_dn8 hur_landfall_dn7 ///
	  hur_landfall_dn6 hur_landfall_dn5 hur_landfall_dn4 hur_landfall_dn3 ///
	  hur_landfall_dn2 hur_landfall_dn1 hur_landfall_d0 hur_landfall_d1 ///
	  hur_landfall_d2 hur_landfall_d3 hur_landfall_d4 hur_landfall_d5 ///
	  hur_landfall_d6 hur_landfall_d7 hur_landfall_d8 hur_landfall_d9 ///
	  hur_landfall_d10 hur_landfall_d11 hur_landfall_d12 hur_landfall_d13 ///
	  hur_landfall_d14, last
egen window_landfall=rowtotal(hur_landfall_dn14-hur_landfall_d14)  //Event study - Landfall

*Coefficient variables
gen d=. in 1
gen xb_hur1 = . in 1
	gen hi_hur1 = . in 1
	gen lo_hur1 = . in 1	
gen xb_hur2 = . in 1
	gen hi_hur2 = . in 1
	gen lo_hur2 = . in 1
gen xb_hur3 = . in 1
	gen hi_hur3 = . in 1
	gen lo_hur3 = . in 1
	
*Hurricane Landfall Areas - Price	
reg retail hur_landfall_dn14-hur_landfall_d14 ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)
		
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur1    = r(estimate) in `i'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur1    = r(estimate) in `j'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `j'
}
*
*Hurricane Landfall Areas - wholesale	
reg wholesale hur_landfall_dn14-hur_landfall_d14  ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)	
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur3    = r(estimate) in `i'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur3    = r(estimate) in `j'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `j'
}
*
*Graph - Prices and Wholesale
tw(connected xb_hur1 d, m(T) mfcolor(white) mlcolor(black) msize(medium) lcolor(edkblue) lwidth(medthick) mlwidth(medium)) ///
 (connected xb_hur3 d, m(circle) mfcolor(white) mlcolor(black) msize(medium) lcolor(cranberry) lwidth(medthick) mlwidth(medium)) , ///
	graphr(color(white)) ///
	yscale(noline) ///
	xtit("Days Before/After Hurricane Landfall") ///
	ytit("Price ($/gal)") ///
	legend(label(1 "Retail") ///
		   label(2 "Wholesale") ring(0) position(11) col(1) region(lcolor(white)) )  ///
	text(4 0 "Ivan", size(medium)) ///
	ylabel(0(0.5)4 ,nogrid angle(0)) ///
	xlabel(-14(2)14) 
graph export $figs/ivan-whole-ret-$outputdate.png, replace
drop event_day-lo_hur3


********************************
*EVENT STUDY: JEANNE 
*Hurricane landfalls day 0
gsort station_id date
gen hur_landfall_d0=0 
	replace hur_landfall_d0=1 if JEANNE_landfall==1 & date==`=td(26sep2004)'
*
*Creating 14-day event windows   
gen event_day=. //Event day variable
	replace event_day=0 if hur_landfall_d0==1 
	
*Indicators: 14 Days Prior to Hurricane for Different Samples
forvalues t = 1/14 {
	local n=-1*(`t')
	*Year check
	gen y=f`t'.year
	*Landfall 
	gen hur_landfall_dn`t' = 0
		replace hur_landfall_dn`t' = 1 if f`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`n' if hur_landfall_dn`t'==1
	drop y
}
*
*Indicators: 14 Days After Hurricane
forvalues t = 1/14 {
	*Year check
	gen y=l`t'.year
	*Landfall indicator
	gen hur_landfall_d`t' = 0		
		replace hur_landfall_d`t' = 1 if l`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`t' if hur_landfall_d`t'==1
	drop y		
}
*
order hur_landfall_dn14 hur_landfall_dn13 hur_landfall_dn12 hur_landfall_dn11 ///
      hur_landfall_dn10 hur_landfall_dn9 hur_landfall_dn8 hur_landfall_dn7 ///
	  hur_landfall_dn6 hur_landfall_dn5 hur_landfall_dn4 hur_landfall_dn3 ///
	  hur_landfall_dn2 hur_landfall_dn1 hur_landfall_d0 hur_landfall_d1 ///
	  hur_landfall_d2 hur_landfall_d3 hur_landfall_d4 hur_landfall_d5 ///
	  hur_landfall_d6 hur_landfall_d7 hur_landfall_d8 hur_landfall_d9 ///
	  hur_landfall_d10 hur_landfall_d11 hur_landfall_d12 hur_landfall_d13 ///
	  hur_landfall_d14, last
egen window_landfall=rowtotal(hur_landfall_dn14-hur_landfall_d14)  //Event study - Landfall

*Coefficient variables
gen d=. in 1
gen xb_hur1 = . in 1
	gen hi_hur1 = . in 1
	gen lo_hur1 = . in 1	
gen xb_hur2 = . in 1
	gen hi_hur2 = . in 1
	gen lo_hur2 = . in 1
gen xb_hur3 = . in 1
	gen hi_hur3 = . in 1
	gen lo_hur3 = . in 1
	
*Hurricane Landfall Areas - Price	
reg retail hur_landfall_dn14-hur_landfall_d14 ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)
		
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur1    = r(estimate) in `i'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur1    = r(estimate) in `j'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `j'
}
*
*Hurricane Landfall Areas - wholesale	
reg wholesale hur_landfall_dn14-hur_landfall_d14  ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)	
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur3    = r(estimate) in `i'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur3    = r(estimate) in `j'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `j'
}
*
*Graph - Prices and Wholesale
tw(connected xb_hur1 d, m(T) mfcolor(white) mlcolor(black) msize(medium) lcolor(edkblue) lwidth(medthick) mlwidth(medium)) ///
 (connected xb_hur3 d, m(circle) mfcolor(white) mlcolor(black) msize(medium) lcolor(cranberry) lwidth(medthick) mlwidth(medium)) , ///
	graphr(color(white)) ///
	yscale(noline) ///
	xtit("Days Before/After Hurricane Landfall") ///
	ytit("Price ($/gal)") ///
	legend(label(1 "Retail") ///
		   label(2 "Wholesale") ring(0) position(11) col(1) region(lcolor(white)) )  ///
	text(4 0 "Jeanne", size(medium)) ///
	ylabel(0(0.5)4 ,nogrid angle(0)) ///
	xlabel(-14(2)14) 
graph export $figs/jeanne-whole-ret-$outputdate.png, replace
drop event_day-lo_hur3


********************************
*EVENT STUDY: ARLENE 
*Hurricane landfalls day 0
gsort station_id date
gen hur_landfall_d0=0 
	replace hur_landfall_d0=1 if ARLENE_landfall==1 & date==`=td(11jun2005)'	
*
*Creating 14-day event windows   
gen event_day=. //Event day variable
	replace event_day=0 if hur_landfall_d0==1 
	
*Indicators: 14 Days Prior to Hurricane for Different Samples
forvalues t = 1/10 {
	local n=-1*(`t')
	*Year check
	gen y=f`t'.year
	*Landfall 
	gen hur_landfall_dn`t' = 0
		replace hur_landfall_dn`t' = 1 if f`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`n' if hur_landfall_dn`t'==1
	drop y
}
*
*Indicators: 14 Days After Hurricane
forvalues t = 1/14 {
	*Year check
	gen y=l`t'.year
	*Landfall indicator
	gen hur_landfall_d`t' = 0		
		replace hur_landfall_d`t' = 1 if l`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`t' if hur_landfall_d`t'==1
	drop y		
}
*
order hur_landfall_dn10 hur_landfall_dn9 hur_landfall_dn8 hur_landfall_dn7 ///
	  hur_landfall_dn6 hur_landfall_dn5 hur_landfall_dn4 hur_landfall_dn3 ///
	  hur_landfall_dn2 hur_landfall_dn1 hur_landfall_d0 hur_landfall_d1 ///
	  hur_landfall_d2 hur_landfall_d3 hur_landfall_d4 hur_landfall_d5 ///
	  hur_landfall_d6 hur_landfall_d7 hur_landfall_d8 hur_landfall_d9 ///
	  hur_landfall_d10 hur_landfall_d11 hur_landfall_d12 hur_landfall_d13 ///
	  hur_landfall_d14, last
egen window_landfall=rowtotal(hur_landfall_dn10-hur_landfall_d14)  //Event study - Landfall

*Coefficient variables
gen d=. in 1
gen xb_hur1 = . in 1
	gen hi_hur1 = . in 1
	gen lo_hur1 = . in 1	
gen xb_hur2 = . in 1
	gen hi_hur2 = . in 1
	gen lo_hur2 = . in 1
gen xb_hur3 = . in 1
	gen hi_hur3 = . in 1
	gen lo_hur3 = . in 1
	
*Hurricane Landfall Areas - Price	
reg retail hur_landfall_dn10-hur_landfall_d14 ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)
		
forvalues i = 1/10 {
	local j=-1*(`i'-11)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur1    = r(estimate) in `i'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur1    = r(estimate) in `j'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `j'
}
*
*Hurricane Landfall Areas - wholesale	
reg wholesale hur_landfall_dn10-hur_landfall_d14  ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)	
forvalues i = 1/10 {
	local j=-1*(`i'-11)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur3    = r(estimate) in `i'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur3    = r(estimate) in `j'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `j'
}
*
*Graph - Prices and Wholesale
tw(connected xb_hur1 d, m(T) mfcolor(white) mlcolor(black) msize(medium) lcolor(edkblue) lwidth(medthick) mlwidth(medium)) ///
 (connected xb_hur3 d, m(circle) mfcolor(white) mlcolor(black) msize(medium) lcolor(cranberry) lwidth(medthick) mlwidth(medium)) , ///
	graphr(color(white)) ///
	yscale(noline) ///
	xtit("Days Before/After Hurricane Landfall") ///
	ytit("Price ($/gal)") ///
	legend(label(1 "Retail") ///
		   label(2 "Wholesale") ring(0) position(11) col(1) region(lcolor(white)) )  ///
	text(4 0 "Arlene", size(medium)) ///
	ylabel(0(0.5)4 ,nogrid angle(0)) ///
	xlabel(-14(2)14) 
graph export $figs/arlene-whole-ret-$outputdate.png, replace
drop event_day-lo_hur3


********************************
*EVENT STUDY: DENNIS 
gsort station_id date
gen hur_landfall_d0=0 
	replace hur_landfall_d0=1 if DENNIS_landfall==1 & date==`=td(10jul2005)'	
*
*Creating 14-day event windows   
gen event_day=. //Event day variable
	replace event_day=0 if hur_landfall_d0==1 
	
*Indicators: 14 Days Prior to Hurricane for Different Samples
forvalues t = 1/14 {
	local n=-1*(`t')
	*Year check
	gen y=f`t'.year
	*Landfall 
	gen hur_landfall_dn`t' = 0
		replace hur_landfall_dn`t' = 1 if f`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`n' if hur_landfall_dn`t'==1
	drop y
}
*
*Indicators: 14 Days After Hurricane
forvalues t = 1/14 {
	*Year check
	gen y=l`t'.year
	*Landfall indicator
	gen hur_landfall_d`t' = 0		
		replace hur_landfall_d`t' = 1 if l`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`t' if hur_landfall_d`t'==1
	drop y		
}
*
order hur_landfall_dn14 hur_landfall_dn13 hur_landfall_dn12 hur_landfall_dn11 ///
      hur_landfall_dn10 hur_landfall_dn9 hur_landfall_dn8 hur_landfall_dn7 ///
	  hur_landfall_dn6 hur_landfall_dn5 hur_landfall_dn4 hur_landfall_dn3 ///
	  hur_landfall_dn2 hur_landfall_dn1 hur_landfall_d0 hur_landfall_d1 ///
	  hur_landfall_d2 hur_landfall_d3 hur_landfall_d4 hur_landfall_d5 ///
	  hur_landfall_d6 hur_landfall_d7 hur_landfall_d8 hur_landfall_d9 ///
	  hur_landfall_d10 hur_landfall_d11 hur_landfall_d12 hur_landfall_d13 ///
	  hur_landfall_d14, last
egen window_landfall=rowtotal(hur_landfall_dn14-hur_landfall_d14)  //Event study - Landfall

*Coefficient variables
gen d=. in 1
gen xb_hur1 = . in 1
	gen hi_hur1 = . in 1
	gen lo_hur1 = . in 1	
gen xb_hur2 = . in 1
	gen hi_hur2 = . in 1
	gen lo_hur2 = . in 1
gen xb_hur3 = . in 1
	gen hi_hur3 = . in 1
	gen lo_hur3 = . in 1
	
*Hurricane Landfall Areas - Price	
reg retail hur_landfall_dn14-hur_landfall_d14 ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)
		
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur1    = r(estimate) in `i'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur1    = r(estimate) in `j'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `j'
}
*
*Hurricane Landfall Areas - wholesale	
reg wholesale hur_landfall_dn14-hur_landfall_d14  ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)	
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur3    = r(estimate) in `i'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur3    = r(estimate) in `j'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `j'
}
*
*Graph - Prices and Wholesale
tw(connected xb_hur1 d, m(T) mfcolor(white) mlcolor(black) msize(medium) lcolor(edkblue) lwidth(medthick) mlwidth(medium)) ///
 (connected xb_hur3 d, m(circle) mfcolor(white) mlcolor(black) msize(medium) lcolor(cranberry) lwidth(medthick) mlwidth(medium)) , ///
	graphr(color(white)) ///
	yscale(noline) ///
	xtit("Days Before/After Hurricane Landfall") ///
	ytit("Price ($/gal)") ///
	legend(label(1 "Retail") ///
		   label(2 "Wholesale") ring(0) position(11) col(1) region(lcolor(white)) )  ///
	text(4 0 "Dennis", size(medium)) ///
	ylabel(0(0.5)4 ,nogrid angle(0)) ///
	xlabel(-14(2)14) 
graph export $figs/dennis-whole-ret-$outputdate.png, replace
drop event_day-lo_hur3


********************************
*EVENT STUDY: KATRINA (FL) 
gsort station_id date
gen hur_landfall_d0=0 
	replace hur_landfall_d0=1 if KATRINA_FL_landfall==1 & date==`=td(25aug2005)'
*
*Creating 14-day event windows   
gen event_day=. //Event day variable
	replace event_day=0 if hur_landfall_d0==1 
	
*Indicators: 14 Days Prior to Hurricane for Different Samples
forvalues t = 1/14 {
	local n=-1*(`t')
	*Year check
	gen y=f`t'.year
	*Landfall 
	gen hur_landfall_dn`t' = 0
		replace hur_landfall_dn`t' = 1 if f`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`n' if hur_landfall_dn`t'==1
	drop y
}
*
*Indicators: 14 Days After Hurricane
forvalues t = 1/14 {
	*Year check
	gen y=l`t'.year
	*Landfall indicator
	gen hur_landfall_d`t' = 0		
		replace hur_landfall_d`t' = 1 if l`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`t' if hur_landfall_d`t'==1
	drop y		
}
*
order hur_landfall_dn14 hur_landfall_dn13 hur_landfall_dn12 hur_landfall_dn11 ///
      hur_landfall_dn10 hur_landfall_dn9 hur_landfall_dn8 hur_landfall_dn7 ///
	  hur_landfall_dn6 hur_landfall_dn5 hur_landfall_dn4 hur_landfall_dn3 ///
	  hur_landfall_dn2 hur_landfall_dn1 hur_landfall_d0 hur_landfall_d1 ///
	  hur_landfall_d2 hur_landfall_d3 hur_landfall_d4 hur_landfall_d5 ///
	  hur_landfall_d6 hur_landfall_d7 hur_landfall_d8 hur_landfall_d9 ///
	  hur_landfall_d10 hur_landfall_d11 hur_landfall_d12 hur_landfall_d13 ///
	  hur_landfall_d14, last
egen window_landfall=rowtotal(hur_landfall_dn14-hur_landfall_d14)  //Event study - Landfall

*Coefficient variables
gen d=. in 1
gen xb_hur1 = . in 1
	gen hi_hur1 = . in 1
	gen lo_hur1 = . in 1	
gen xb_hur2 = . in 1
	gen hi_hur2 = . in 1
	gen lo_hur2 = . in 1
gen xb_hur3 = . in 1
	gen hi_hur3 = . in 1
	gen lo_hur3 = . in 1
	
*Hurricane Landfall Areas - Price	
reg retail hur_landfall_dn14-hur_landfall_d14 ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur1    = r(estimate) in `i'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur1    = r(estimate) in `j'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `j'
}
*
*Hurricane Landfall Areas - wholesale	
reg wholesale hur_landfall_dn14-hur_landfall_d14  ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)	
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur3    = r(estimate) in `i'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur3    = r(estimate) in `j'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `j'
}
*
*Graph - Prices and Wholesale
tw(connected xb_hur1 d, m(T) mfcolor(white) mlcolor(black) msize(medium) lcolor(edkblue) lwidth(medthick) mlwidth(medium)) ///
 (connected xb_hur3 d, m(circle) mfcolor(white) mlcolor(black) msize(medium) lcolor(cranberry) lwidth(medthick) mlwidth(medium)) , ///
	graphr(color(white)) ///
	yscale(noline) ///
	xtit("Days Before/After Hurricane Landfall") ///
	ytit("Price ($/gal)") ///
	legend(label(1 "Retail") ///
		   label(2 "Wholesale") ring(0) position(11) col(1) region(lcolor(white)) )  ///
	text(4 0 "Katrina (FL)", size(medium)) ///
	ylabel(0(0.5)4 ,nogrid angle(0)) ///
	xlabel(-14(2)14) 
graph export $figs/katrina-fl-whole-ret-$outputdate.png, replace
drop event_day-lo_hur3



********************************
*EVENT STUDY: KATRINA (LA) 
gsort station_id date
gen hur_landfall_d0=0 
	replace hur_landfall_d0=1 if KATRINA_LA_landfall==1 & date==`=td(29aug2005)'
*
*Creating 14-day event windows   
gen event_day=. //Event day variable
	replace event_day=0 if hur_landfall_d0==1 
	
*Indicators: 14 Days Prior to Hurricane for Different Samples
forvalues t = 1/14 {
	local n=-1*(`t')
	*Year check
	gen y=f`t'.year
	*Landfall 
	gen hur_landfall_dn`t' = 0
		replace hur_landfall_dn`t' = 1 if f`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`n' if hur_landfall_dn`t'==1
	drop y
}
*
*Indicators: 14 Days After Hurricane
forvalues t = 1/14 {
	*Year check
	gen y=l`t'.year
	*Landfall indicator
	gen hur_landfall_d`t' = 0		
		replace hur_landfall_d`t' = 1 if l`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`t' if hur_landfall_d`t'==1
	drop y		
}
*
order hur_landfall_dn14 hur_landfall_dn13 hur_landfall_dn12 hur_landfall_dn11 ///
      hur_landfall_dn10 hur_landfall_dn9 hur_landfall_dn8 hur_landfall_dn7 ///
	  hur_landfall_dn6 hur_landfall_dn5 hur_landfall_dn4 hur_landfall_dn3 ///
	  hur_landfall_dn2 hur_landfall_dn1 hur_landfall_d0 hur_landfall_d1 ///
	  hur_landfall_d2 hur_landfall_d3 hur_landfall_d4 hur_landfall_d5 ///
	  hur_landfall_d6 hur_landfall_d7 hur_landfall_d8 hur_landfall_d9 ///
	  hur_landfall_d10 hur_landfall_d11 hur_landfall_d12 hur_landfall_d13 ///
	  hur_landfall_d14, last
egen window_landfall=rowtotal(hur_landfall_dn14-hur_landfall_d14)  //Event study - Landfall

*Coefficient variables
gen d=. in 1
gen xb_hur1 = . in 1
	gen hi_hur1 = . in 1
	gen lo_hur1 = . in 1	
gen xb_hur2 = . in 1
	gen hi_hur2 = . in 1
	gen lo_hur2 = . in 1
gen xb_hur3 = . in 1
	gen hi_hur3 = . in 1
	gen lo_hur3 = . in 1
	
*Hurricane Landfall Areas - Price	
reg retail hur_landfall_dn14-hur_landfall_d14 ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)
		
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur1    = r(estimate) in `i'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur1    = r(estimate) in `j'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `j'
}
*
*Hurricane Landfall Areas - wholesale	
reg wholesale hur_landfall_dn14-hur_landfall_d14  ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)	
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur3    = r(estimate) in `i'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur3    = r(estimate) in `j'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `j'
}
*
*Graph - Prices and Wholesale
tw(connected xb_hur1 d, m(T) mfcolor(white) mlcolor(black) msize(medium) lcolor(edkblue) lwidth(medthick) mlwidth(medium)) ///
 (connected xb_hur3 d, m(circle) mfcolor(white) mlcolor(black) msize(medium) lcolor(cranberry) lwidth(medthick) mlwidth(medium)) , ///
	graphr(color(white)) ///
	yscale(noline) ///
	xtit("Days Before/After Hurricane Landfall") ///
	ytit("Price ($/gal)") ///
	legend(label(1 "Retail") ///
		   label(2 "Wholesale") ring(0) position(11) col(1) region(lcolor(white)) )  ///
	text(4 0 "Katrina (LA)", size(medium)) ///
	ylabel(0(0.5)4 ,nogrid angle(0)) ///
	xlabel(-14(2)14) 
graph export $figs/katrina-la-whole-ret-$outputdate.png, replace
drop event_day-lo_hur3


********************************
*EVENT STUDY: RITA 
gsort station_id date
gen hur_landfall_d0=0 
	replace hur_landfall_d0=1 if RITA_landfall==1 & date==`=td(24sep2005)'
*
*Creating 14-day event windows   
gen event_day=. //Event day variable
	replace event_day=0 if hur_landfall_d0==1 
	
*Indicators: 14 Days Prior to Hurricane for Different Samples
forvalues t = 1/14 {
	local n=-1*(`t')
	*Year check
	gen y=f`t'.year
	*Landfall 
	gen hur_landfall_dn`t' = 0
		replace hur_landfall_dn`t' = 1 if f`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`n' if hur_landfall_dn`t'==1
	drop y
}
*
*Indicators: 14 Days After Hurricane
forvalues t = 1/14 {
	*Year check
	gen y=l`t'.year
	*Landfall indicator
	gen hur_landfall_d`t' = 0		
		replace hur_landfall_d`t' = 1 if l`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`t' if hur_landfall_d`t'==1
	drop y		
}
*
order hur_landfall_dn14 hur_landfall_dn13 hur_landfall_dn12 hur_landfall_dn11 ///
      hur_landfall_dn10 hur_landfall_dn9 hur_landfall_dn8 hur_landfall_dn7 ///
	  hur_landfall_dn6 hur_landfall_dn5 hur_landfall_dn4 hur_landfall_dn3 ///
	  hur_landfall_dn2 hur_landfall_dn1 hur_landfall_d0 hur_landfall_d1 ///
	  hur_landfall_d2 hur_landfall_d3 hur_landfall_d4 hur_landfall_d5 ///
	  hur_landfall_d6 hur_landfall_d7 hur_landfall_d8 hur_landfall_d9 ///
	  hur_landfall_d10 hur_landfall_d11 hur_landfall_d12 hur_landfall_d13 ///
	  hur_landfall_d14, last
egen window_landfall=rowtotal(hur_landfall_dn14-hur_landfall_d14)  //Event study - Landfall

*Coefficient variables
gen d=. in 1
gen xb_hur1 = . in 1
	gen hi_hur1 = . in 1
	gen lo_hur1 = . in 1	
gen xb_hur2 = . in 1
	gen hi_hur2 = . in 1
	gen lo_hur2 = . in 1
gen xb_hur3 = . in 1
	gen hi_hur3 = . in 1
	gen lo_hur3 = . in 1
	
*Hurricane Landfall Areas - Price	
reg retail hur_landfall_dn14-hur_landfall_d14 ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)
		
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur1    = r(estimate) in `i'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur1    = r(estimate) in `j'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `j'
}
*
*Hurricane Landfall Areas - wholesale	
reg wholesale hur_landfall_dn14-hur_landfall_d14  ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)	
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur3    = r(estimate) in `i'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur3    = r(estimate) in `j'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `j'
}
*
*Graph - Prices and Wholesale
tw(connected xb_hur1 d, m(T) mfcolor(white) mlcolor(black) msize(medium) lcolor(edkblue) lwidth(medthick) mlwidth(medium)) ///
 (connected xb_hur3 d, m(circle) mfcolor(white) mlcolor(black) msize(medium) lcolor(cranberry) lwidth(medthick) mlwidth(medium)) , ///
	graphr(color(white)) ///
	yscale(noline) ///
	xtit("Days Before/After Hurricane Landfall") ///
	ytit("Price ($/gal)") ///
	legend(label(1 "Retail") ///
		   label(2 "Wholesale") ring(0) position(11) col(1) region(lcolor(white)) )  ///
	text(4 0 "Rita", size(medium)) ///
	ylabel(0(0.5)4 ,nogrid angle(0)) ///
	xlabel(-14(2)14) 
graph export $figs/rita-whole-ret-$outputdate.png, replace
drop event_day-lo_hur3


********************************
*EVENT STUDY: WILMA 
gsort station_id date
gen hur_landfall_d0=0 
	replace hur_landfall_d0=1 if WILMA_landfall==1 & date==`=td(24oct2005)'
*
*Creating 14-day event windows   
gen event_day=. //Event day variable
	replace event_day=0 if hur_landfall_d0==1 
	
*Indicators: 14 Days Prior to Hurricane for Different Samples
forvalues t = 1/14 {
	local n=-1*(`t')
	*Year check
	gen y=f`t'.year
	*Landfall 
	gen hur_landfall_dn`t' = 0
		replace hur_landfall_dn`t' = 1 if f`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`n' if hur_landfall_dn`t'==1
	drop y
}
*
*Indicators: 7 Days After Hurricane
forvalues t = 1/7 {
	*Year check
	gen y=l`t'.year
	*Landfall indicator
	gen hur_landfall_d`t' = 0		
		replace hur_landfall_d`t' = 1 if l`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`t' if hur_landfall_d`t'==1
	drop y		
}
*
order hur_landfall_dn14 hur_landfall_dn13 hur_landfall_dn12 hur_landfall_dn11 ///
      hur_landfall_dn10 hur_landfall_dn9 hur_landfall_dn8 hur_landfall_dn7 ///
	  hur_landfall_dn6 hur_landfall_dn5 hur_landfall_dn4 hur_landfall_dn3 ///
	  hur_landfall_dn2 hur_landfall_dn1 hur_landfall_d0 hur_landfall_d1 ///
	  hur_landfall_d2 hur_landfall_d3 hur_landfall_d4 hur_landfall_d5 ///
	  hur_landfall_d6 hur_landfall_d7
egen window_landfall=rowtotal(hur_landfall_dn14-hur_landfall_d7)  //Event study - Landfall

*Coefficient variables
gen d=. in 1
gen xb_hur1 = . in 1
	gen hi_hur1 = . in 1
	gen lo_hur1 = . in 1	
gen xb_hur2 = . in 1
	gen hi_hur2 = . in 1
	gen lo_hur2 = . in 1
gen xb_hur3 = . in 1
	gen hi_hur3 = . in 1
	gen lo_hur3 = . in 1
	
*Hurricane Landfall Areas - Price	
reg retail hur_landfall_dn14-hur_landfall_d7 ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)
		
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur1    = r(estimate) in `i'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/7 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur1    = r(estimate) in `j'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `j'
}
*
*Hurricane Landfall Areas - wholesale	
reg wholesale hur_landfall_dn14-hur_landfall_d7  ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)	
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur3    = r(estimate) in `i'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/7 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur3    = r(estimate) in `j'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `j'
}
*
*Graph - Prices and Wholesale
tw(connected xb_hur1 d, m(T) mfcolor(white) mlcolor(black) msize(medium) lcolor(edkblue) lwidth(medthick) mlwidth(medium)) ///
 (connected xb_hur3 d, m(circle) mfcolor(white) mlcolor(black) msize(medium) lcolor(cranberry) lwidth(medthick) mlwidth(medium)) , ///
	graphr(color(white)) ///
	yscale(noline) ///
	xtit("Days Before/After Hurricane Landfall") ///
	ytit("Price ($/gal)") ///
	legend(label(1 "Retail") ///
		   label(2 "Wholesale") ring(0) position(11) col(1) region(lcolor(white)) )  ///
	text(4 0 "Wilma", size(medium)) ///
	ylabel(0(0.5)4 ,nogrid angle(0)) ///
	xlabel(-14(2)14) 
graph export $figs/wilma-whole-ret-$outputdate.png, replace
drop event_day-lo_hur3
drop hur_landfall_dn14-hur_landfall_d7


********************************
*EVENT STUDY: ALBERTO 
*Hurricane landfalls day 0
gsort station_id date
gen hur_landfall_d0=0 
	replace hur_landfall_d0=1 if ALBERTO_landfall==1 & date==`=td(13jun2006)'
*
*Creating 12-day event windows   
gen event_day=. //Event day variable
	replace event_day=0 if hur_landfall_d0==1 
	
*Indicators: 12 Days Prior to Hurricane for Different Samples
forvalues t = 1/12 {
	local n=-1*(`t')
	*Year check
	gen y=f`t'.year
	*Landfall 
	gen hur_landfall_dn`t' = 0
		replace hur_landfall_dn`t' = 1 if f`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`n' if hur_landfall_dn`t'==1
	drop y
}
*
*Indicators: 14 Days After Hurricane
forvalues t = 1/14 {
	*Year check
	gen y=l`t'.year
	*Landfall indicator
	gen hur_landfall_d`t' = 0		
		replace hur_landfall_d`t' = 1 if l`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`t' if hur_landfall_d`t'==1
	drop y		
}
*
order hur_landfall_dn12 hur_landfall_dn11 ///
      hur_landfall_dn10 hur_landfall_dn9 hur_landfall_dn8 hur_landfall_dn7 ///
	  hur_landfall_dn6 hur_landfall_dn5 hur_landfall_dn4 hur_landfall_dn3 ///
	  hur_landfall_dn2 hur_landfall_dn1 hur_landfall_d0 hur_landfall_d1 ///
	  hur_landfall_d2 hur_landfall_d3 hur_landfall_d4 hur_landfall_d5 ///
	  hur_landfall_d6 hur_landfall_d7 hur_landfall_d8 hur_landfall_d9 ///
	  hur_landfall_d10 hur_landfall_d11 hur_landfall_d12 hur_landfall_d13 ///
	  hur_landfall_d14, last
egen window_landfall=rowtotal(hur_landfall_dn12-hur_landfall_d14)  //Event study - Landfall

*Coefficient variables
gen d=. in 1
gen xb_hur1 = . in 1
	gen hi_hur1 = . in 1
	gen lo_hur1 = . in 1	
gen xb_hur2 = . in 1
	gen hi_hur2 = . in 1
	gen lo_hur2 = . in 1
gen xb_hur3 = . in 1
	gen hi_hur3 = . in 1
	gen lo_hur3 = . in 1
	
*Hurricane Landfall Areas - Price	
reg retail hur_landfall_dn12-hur_landfall_d14 ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)
		
forvalues i = 1/12 {
	local j=-1*(`i'-13)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur1    = r(estimate) in `i'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur1    = r(estimate) in `j'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `j'
}
*
*Hurricane Landfall Areas - wholesale	
reg wholesale hur_landfall_dn12-hur_landfall_d14  ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)	
forvalues i = 1/12 {
	local j=-1*(`i'-13)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur3    = r(estimate) in `i'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur3    = r(estimate) in `j'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `j'
}
*
*Graph - Prices and Wholesale
tw(connected xb_hur1 d, m(T) mfcolor(white) mlcolor(black) msize(medium) lcolor(edkblue) lwidth(medthick) mlwidth(medium)) ///
 (connected xb_hur3 d, m(circle) mfcolor(white) mlcolor(black) msize(medium) lcolor(cranberry) lwidth(medthick) mlwidth(medium)) , ///
	graphr(color(white)) ///
	yscale(noline) ///
	xtit("Days Before/After Hurricane Landfall") ///
	ytit("Price ($/gal)") ///
	legend(label(1 "Retail") ///
		   label(2 "Wholesale") ring(0) position(11) col(1) region(lcolor(white)) )  ///
	text(4 0 "Alberto", size(medium)) ///
	ylabel(0(0.5)4 ,nogrid angle(0)) ///
	xlabel(-14(2)14) 
graph export $figs/alberto-whole-ret-$outputdate.png, replace
drop event_day-lo_hur3


********************************
*EVENT STUDY: HUMBERTO 
gsort station_id date
gen hur_landfall_d0=0 
	replace hur_landfall_d0=1 if HUMBERTO_landfall==1 & date==`=td(13sep2007)'
*
*Creating 14-day event windows   
gen event_day=. //Event day variable
	replace event_day=0 if hur_landfall_d0==1 
	
*Indicators: 14 Days Prior to Hurricane for Different Samples
forvalues t = 1/14 {
	local n=-1*(`t')
	*Year check
	gen y=f`t'.year
	*Landfall 
	gen hur_landfall_dn`t' = 0
		replace hur_landfall_dn`t' = 1 if f`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`n' if hur_landfall_dn`t'==1
	drop y
}
*
*Indicators: 14 Days After Hurricane
forvalues t = 1/14 {
	*Year check
	gen y=l`t'.year
	*Landfall indicator
	gen hur_landfall_d`t' = 0		
		replace hur_landfall_d`t' = 1 if l`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`t' if hur_landfall_d`t'==1
	drop y		
}
*
order hur_landfall_dn14 hur_landfall_dn13 hur_landfall_dn12 hur_landfall_dn11 ///
      hur_landfall_dn10 hur_landfall_dn9 hur_landfall_dn8 hur_landfall_dn7 ///
	  hur_landfall_dn6 hur_landfall_dn5 hur_landfall_dn4 hur_landfall_dn3 ///
	  hur_landfall_dn2 hur_landfall_dn1 hur_landfall_d0 hur_landfall_d1 ///
	  hur_landfall_d2 hur_landfall_d3 hur_landfall_d4 hur_landfall_d5 ///
	  hur_landfall_d6 hur_landfall_d7 hur_landfall_d8 hur_landfall_d9 ///
	  hur_landfall_d10 hur_landfall_d11 hur_landfall_d12 hur_landfall_d13 ///
	  hur_landfall_d14, last
egen window_landfall=rowtotal(hur_landfall_dn14-hur_landfall_d14)  //Event study - Landfall

*Coefficient variables
gen d=. in 1
gen xb_hur1 = . in 1
	gen hi_hur1 = . in 1
	gen lo_hur1 = . in 1	
gen xb_hur2 = . in 1
	gen hi_hur2 = . in 1
	gen lo_hur2 = . in 1
gen xb_hur3 = . in 1
	gen hi_hur3 = . in 1
	gen lo_hur3 = . in 1
	
*Hurricane Landfall Areas - Price	
reg retail hur_landfall_dn14-hur_landfall_d14 ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)
		
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur1    = r(estimate) in `i'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur1    = r(estimate) in `j'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `j'
}
*
*Hurricane Landfall Areas - wholesale	
reg wholesale hur_landfall_dn14-hur_landfall_d14  ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)	
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur3    = r(estimate) in `i'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur3    = r(estimate) in `j'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `j'
}
*
*Graph - Prices and Wholesale
tw(connected xb_hur1 d, m(T) mfcolor(white) mlcolor(black) msize(medium) lcolor(edkblue) lwidth(medthick) mlwidth(medium)) ///
 (connected xb_hur3 d, m(circle) mfcolor(white) mlcolor(black) msize(medium) lcolor(cranberry) lwidth(medthick) mlwidth(medium)) , ///
	graphr(color(white)) ///
	yscale(noline) ///
	xtit("Days Before/After Hurricane Landfall") ///
	ytit("Price ($/gal)") ///
	legend(label(1 "Retail") ///
		   label(2 "Wholesale") ring(0) position(11) col(1) region(lcolor(white)) )  ///
	text(4 0 "Humberto", size(medium)) ///
	ylabel(0(0.5)4 ,nogrid angle(0)) ///
	xlabel(-14(2)14) 
graph export $figs/humberto-whole-ret-$outputdate.png, replace
drop event_day-lo_hur3


********************************
*EVENT STUDY: GUSTAV 
gsort station_id date
gen hur_landfall_d0=0 
	replace hur_landfall_d0=1 if GUSTAV_landfall==1 & date==`=td(01sep2008)'	
*
*Creating 14-day event windows   
gen event_day=. //Event day variable
	replace event_day=0 if hur_landfall_d0==1 
	
*Indicators: 14 Days Prior to Hurricane for Different Samples
forvalues t = 1/14 {
	local n=-1*(`t')
	*Year check
	gen y=f`t'.year
	*Landfall 
	gen hur_landfall_dn`t' = 0
		replace hur_landfall_dn`t' = 1 if f`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`n' if hur_landfall_dn`t'==1
	drop y
}
*
*Indicators: 14 Days After Hurricane
forvalues t = 1/14 {
	*Year check
	gen y=l`t'.year
	*Landfall indicator
	gen hur_landfall_d`t' = 0		
		replace hur_landfall_d`t' = 1 if l`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`t' if hur_landfall_d`t'==1
	drop y		
}
*
order hur_landfall_dn14 hur_landfall_dn13 hur_landfall_dn12 hur_landfall_dn11 ///
      hur_landfall_dn10 hur_landfall_dn9 hur_landfall_dn8 hur_landfall_dn7 ///
	  hur_landfall_dn6 hur_landfall_dn5 hur_landfall_dn4 hur_landfall_dn3 ///
	  hur_landfall_dn2 hur_landfall_dn1 hur_landfall_d0 hur_landfall_d1 ///
	  hur_landfall_d2 hur_landfall_d3 hur_landfall_d4 hur_landfall_d5 ///
	  hur_landfall_d6 hur_landfall_d7 hur_landfall_d8 hur_landfall_d9 ///
	  hur_landfall_d10 hur_landfall_d11 hur_landfall_d12 hur_landfall_d13 ///
	  hur_landfall_d14, last
egen window_landfall=rowtotal(hur_landfall_dn14-hur_landfall_d14)  //Event study - Landfall

*Coefficient variables
gen d=. in 1
gen xb_hur1 = . in 1
	gen hi_hur1 = . in 1
	gen lo_hur1 = . in 1	
gen xb_hur2 = . in 1
	gen hi_hur2 = . in 1
	gen lo_hur2 = . in 1
gen xb_hur3 = . in 1
	gen hi_hur3 = . in 1
	gen lo_hur3 = . in 1
	
*Hurricane Landfall Areas - Price	
reg retail hur_landfall_dn14-hur_landfall_d14 ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)	
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur1    = r(estimate) in `i'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur1    = r(estimate) in `j'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `j'
}
*
*Hurricane Landfall Areas - wholesale	
reg wholesale hur_landfall_dn14-hur_landfall_d14  ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)	
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur3    = r(estimate) in `i'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur3    = r(estimate) in `j'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `j'
}
*
*Graph - Prices and Wholesale
tw(connected xb_hur1 d, m(T) mfcolor(white) mlcolor(black) msize(medium) lcolor(edkblue) lwidth(medthick) mlwidth(medium)) ///
 (connected xb_hur3 d, m(circle) mfcolor(white) mlcolor(black) msize(medium) lcolor(cranberry) lwidth(medthick) mlwidth(medium)) , ///
	graphr(color(white)) ///
	yscale(noline) ///
	xtit("Days Before/After Hurricane Landfall") ///
	ytit("Price ($/gal)") ///
	legend(label(1 "Retail") ///
		   label(2 "Wholesale") ring(0) position(7) col(1) region(lcolor(white)) )  ///
	text(4 0 "Gustav", size(medium)) ///
	ylabel(0(0.5)4 ,nogrid angle(0)) ///
	xlabel(-14(2)14) 
graph export $figs/gustav-whole-ret-$outputdate.png, replace
drop event_day-lo_hur3


********************************
*EVENT STUDY: IKE 
gsort station_id date
gen hur_landfall_d0=0 
	replace hur_landfall_d0=1 if IKE_landfall==1 & date==`=td(13sep2008)'
*
*Creating 14-day event windows   
gen event_day=. //Event day variable
	replace event_day=0 if hur_landfall_d0==1 
	
*Indicators: 14 Days Prior to Hurricane for Different Samples
forvalues t = 1/14 {
	local n=-1*(`t')
	*Year check
	gen y=f`t'.year
	*Landfall 
	gen hur_landfall_dn`t' = 0
		replace hur_landfall_dn`t' = 1 if f`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`n' if hur_landfall_dn`t'==1
	drop y
}
*
*Indicators: 14 Days After Hurricane
forvalues t = 1/14 {
	*Year check
	gen y=l`t'.year
	*Landfall indicator
	gen hur_landfall_d`t' = 0		
		replace hur_landfall_d`t' = 1 if l`t'.hur_landfall_d0==1 & y==year
	*Event day  
	replace event_day=`t' if hur_landfall_d`t'==1
	drop y		
}
*
order hur_landfall_dn14 hur_landfall_dn13 hur_landfall_dn12 hur_landfall_dn11 ///
      hur_landfall_dn10 hur_landfall_dn9 hur_landfall_dn8 hur_landfall_dn7 ///
	  hur_landfall_dn6 hur_landfall_dn5 hur_landfall_dn4 hur_landfall_dn3 ///
	  hur_landfall_dn2 hur_landfall_dn1 hur_landfall_d0 hur_landfall_d1 ///
	  hur_landfall_d2 hur_landfall_d3 hur_landfall_d4 hur_landfall_d5 ///
	  hur_landfall_d6 hur_landfall_d7 hur_landfall_d8 hur_landfall_d9 ///
	  hur_landfall_d10 hur_landfall_d11 hur_landfall_d12 hur_landfall_d13 ///
	  hur_landfall_d14, last
egen window_landfall=rowtotal(hur_landfall_dn14-hur_landfall_d14)  //Event study - Landfall

*Coefficient variables
gen d=. in 1
gen xb_hur1 = . in 1
	gen hi_hur1 = . in 1
	gen lo_hur1 = . in 1	
gen xb_hur2 = . in 1
	gen hi_hur2 = . in 1
	gen lo_hur2 = . in 1
gen xb_hur3 = . in 1
	gen hi_hur3 = . in 1
	gen lo_hur3 = . in 1
	
*Hurricane Landfall Areas - Price	
reg retail hur_landfall_dn14-hur_landfall_d14 ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)	
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur1    = r(estimate) in `i'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur1    = r(estimate) in `j'
	replace hi_hur1 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur1 = r(estimate) - 1.96*r(se) in `j'
}
*
*Hurricane Landfall Areas - wholesale	
reg wholesale hur_landfall_dn14-hur_landfall_d14  ///
	  if window_landfall==1, ///
	    nocons cluster(county_FIPS)	
forvalues i = 1/14 {
	local j=-1*(`i'-15)
	replace d=-1*`j' in `i'	
	lincom hur_landfall_dn`j'
	replace xb_hur3    = r(estimate) in `i'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `i'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `i'

}
*
forvalues i = 0/14 {
	local j=`i'+15
	replace d=`i' in `j'
	lincom hur_landfall_d`i'
	replace xb_hur3    = r(estimate) in `j'
	replace hi_hur3 = r(estimate) + 1.96*r(se)  in `j'
	replace lo_hur3 = r(estimate) - 1.96*r(se) in `j'
}
*
*Graph - Prices and Wholesale
tw(connected xb_hur1 d, m(T) mfcolor(white) mlcolor(black) msize(medium) lcolor(edkblue) lwidth(medthick) mlwidth(medium)) ///
 (connected xb_hur3 d, m(circle) mfcolor(white) mlcolor(black) msize(medium) lcolor(cranberry) lwidth(medthick) mlwidth(medium)) , ///
	graphr(color(white)) ///
	yscale(noline) ///
	xtit("Days Before/After Hurricane Landfall") ///
	ytit("Price ($/gal)") ///
	legend(label(1 "Retail") ///
		   label(2 "Wholesale") ring(0) position(7) col(1) region(lcolor(white)) )  ///
	text(4 0 "Ike", size(medium)) ///
	ylabel(0(0.5)4 ,nogrid angle(0)) ///
	xlabel(-14(2)14) 
graph export $figs/ike-whole-ret-$outputdate.png, replace
drop event_day-lo_hur3
frame change default